<?php

namespace RoleUser\Service;

use RoleUser\Mapper\RoleInterface;
use RoleUser\Mapper\RoleMapper;
use Zend\ServiceManager\ServiceManager;
use Zend\ServiceManager\ServiceManagerAwareInterface;

use Admin\Service\AdminUser as  AdminUserService;

class RoleAdminUser extends AdminUserService
{
    CONST ROLE_USER = 2;
    protected $roleMapper;
      /**
     * @var ServiceManager
     */
    protected $serviceManager;
    
    public function setRoleMapper(RoleInterface $roleMapper)
    {
        $this->roleMapper = $roleMapper;
        return $this;
    }

    public function getRoleMapper()
    {
        if (null === $this->roleMapper) {
            die(print_r($this->getServiceManager()));
            $this->roleMapper = $this->getServiceManager()->get('user_role_mapper');die(print '123');
        }
        return $this->roleMapper;

    }


    public function createRoleUser($user , $userRoleMapper)
    {
        if($user) {
            /*---------------------------Role_User-----------------------------------------*/
            $userRole = $user->getRoleUserLinker();
            $userRole->setUserid($user->getUserId());
            /*---------------------------Role_User-----------------------------------------*/
            $userRoleMapper->insert($userRole);
            //$this->getRoleMapper()->insert($userRole);
        }
        return $user;
    }
    
} 